const util = require("../../../utils/util");
var app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    assign_begin_at:"请选择",
    assign_end_at:"请选择"
  },
  // inputblur
  inputBlur(e){
    this.setData({
      [e.currentTarget.dataset.type]:e.detail.value
    })
    
  },
  bindDateChange(e){
    this.setData({
      [e.currentTarget.dataset.type]:e.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if(options){
      this.setData(JSON.parse(options.item))
    }
  },
  // 确认提交
  confrim(){
    wx.request({
      url: app.globalData.urls +( this.data.id ? '/order-manage/edit-coupon' : '/order-manage/add-coupon'),
      header: app.getPostRequestHeader(),
      method: 'POST',
      data: {
        bdmin_user_id:util.getBdmin_user_id(),
        ...(this.data)
      },
      success: (res) => {

        if(res.data.code==200){
          wx.showToast({
            title: '添加成功',
          })
          wx.navigateBack({
            delta: 1,
          })
        }
      }
    })
  },
})